<?php
class P{

	//get all rows
	public static function getAllRows($table)
	{
		$rows = Yii::app()->db->createCommand()
					->select('*')
					->from($table)
					->queryAll();
		return $rows;
	}
	
	public static function generateRandomString($length = 8) {
		$characters = '0123456789abcdefghijk!@#$%^&*()_+<>?":+_)(*&^%$#@!:"lmnopqrstuvwxyzABCDEFGHIJKLMNO!@#$%^&*()_+<>?":+_)(*&^%$#@!:"PQRSTUVWXYZ';
		$randomString = '';
		for ($i = 0; $i < $length; $i++) {
			$randomString .= $characters[rand(0, strlen($characters) - 1)];
		}
		return $randomString;
	}
	
}